let http = require('http');
let https = require('https');
let path = require('path')
let fs = require('fs');

let { ROOT, HTTP_PORT, HTTPS_PORT } = require('../conf');


let httpPort = HTTP_PORT;
let httpsPort = HTTPS_PORT;

module.exports = app => {
    http.createServer(app)
        .listen(httpPort, () => console.log('listen server at' + httpPort))
    
    let cert = fs.readFileSync(path.join(ROOT, './server/ssl/file.crt'))
    let key = fs.readFileSync(path.join(ROOT, './server/ssl/private.pem'))    


    https.createServer({key, cert}, app)
    .listen(httpsPort, () => console.log('listen server at' + httpsPort))

}